using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;


namespace FeedAntGame.Component
{
    /// <summary>
    /// This is a game component that implements IUpdateable.
    /// </summary>
    public class GameOver : Microsoft.Xna.Framework.DrawableGameComponent
    {
        SpriteBatch spriteBatch;
        SpriteFont scoreFont;
        public GameOver(Game game)
            : base(game)
        {
            // TODO: Construct any child components here
        }

        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public override void Initialize()
        {
            // TODO: AddOneCandyFeed your initialization code here
            
            base.Initialize();
        }

        protected override void LoadContent()
        {
            // TODO: AddOneCandyFeed your load content code here
            spriteBatch = new SpriteBatch(Game.GraphicsDevice);
            scoreFont = Game.Content.Load<SpriteFont>(@"fonts\score"); 
            base.LoadContent();
        }
        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            // TODO: AddOneCandyFeed your update code here
            if (Keyboard.GetState().IsKeyDown(Keys.Enter))
                ((GameFA)Game).Exit();
            base.Update(gameTime);
        }

        public override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.AliceBlue);
            spriteBatch.Begin();
            string gameover = "Game Over! The blades win again!";
            spriteBatch.DrawString(scoreFont, gameover,
                new Vector2((Game.Window.ClientBounds.Width / 2)
                - (scoreFont.MeasureString(gameover).X / 2),
                (Game.Window.ClientBounds.Height / 2)
                - (scoreFont.MeasureString(gameover).Y / 2)),
                Color.SaddleBrown);
            gameover = "Your score: " + ((GameFA)Game).currentScore;
            spriteBatch.DrawString(scoreFont, gameover,
                new Vector2((Game.Window.ClientBounds.Width / 2)
                - (scoreFont.MeasureString(gameover).X / 2),
                (Game.Window.ClientBounds.Height / 2)
                - (scoreFont.MeasureString(gameover).Y / 2) + 30),
                Color.SaddleBrown);
            gameover = "(Press ENTER to exit)";
            spriteBatch.DrawString(scoreFont, gameover,
                new Vector2((Game.Window.ClientBounds.Width / 2)
                - (scoreFont.MeasureString(gameover).X / 2),
                (Game.Window.ClientBounds.Height / 2)
                - (scoreFont.MeasureString(gameover).Y / 2) + 60),
                Color.SaddleBrown);
            spriteBatch.End();
            base.Draw(gameTime);
        }
    }
}
